Skip to content

Add model builder for Qwen2_5_VLTextModel#1882

Merged
tianleiwu merged 22 commits into
mainfrom
tlwu/qwen_2_5_vl_txt_model_builder
Dec 5, 2025
Merged

Add model builder for Qwen2_5_VLTextModel#1882
tianleiwu merged 22 commits into
mainfrom
tlwu/qwen_2_5_vl_txt_model_builder

Conversation

@tianleiwu
Copy link
Copy Markdown
Contributor

@tianleiwu tianleiwu commented Nov 19, 2025

Add model builder for Qwen2_5_VLTextModel.

Snippet of example test output:

onnxruntime-genai/test/python/models/qwen_2.5_vl$ bash run.sh fp32

...
--- Comparing Decode Logits ---
Logits: PASS

--- Comparing Decode KV Cache ---
KV Cache (all 72 tensors): PASS

✅ Decode Parity Test Passed!

==============================
🎉 All Parity Tests Passed! 🎉
==============================
--- fp32 run complete ---

Comment thread src/python/py/models/builders/qwen.py Fixed
Comment thread src/python/py/models/builders/qwen.py Fixed
Comment thread src/python/py/models/builders/qwen.py Fixed
Comment thread test/python/models/qwen_2.5_vl/test_qwen_2.5_vl.py Fixed
Comment thread test/python/models/qwen_2.5_vl/test_qwen_2.5_vl.py Fixed
Comment thread test/python/models/qwen_2.5_vl/test_qwen_2.5_vl.py Fixed
Comment thread test/python/models/qwen_2.5_vl/test_qwen_2.5_vl.py Fixed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds model builder support for the Qwen 2.5 VL text model, enabling ONNX export of the language component of this multimodal model. The implementation introduces a new Qwen25VLTextModel class that handles the unique architectural requirements of Qwen 2.5 VL, including 3D positional embeddings and Multi-Dimensional RoPE (MRoPE).

Key changes:

  • New Qwen25VLTextModel class that inherits from QwenModel instead of MistralModel
  • Implementation of dynamic 3D RoPE computation using MRoPE for multimodal positional encoding
  • Comprehensive parity test to validate ONNX model outputs against Hugging Face models

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/python/py/models/builders/qwen.py Adds Qwen25VLTextModel class with MRoPE implementation, custom RoPE cache generation, and model-specific initialization overrides
src/python/py/models/builders/base.py Adds MRoPE configuration support and removes trailing whitespace
src/python/py/models/builder.py Registers Qwen2_5_VLForConditionalGeneration architecture and updates make_model signature to accept config parameter
src/python/py/models/builders/init.py Exports new Qwen25VLTextModel class
src/python/py/models/builders/phi.py Removes blank line (whitespace cleanup)
test/python/models/qwen_2.5_vl/test_qwen_2.5_vl.py Adds comprehensive parity test comparing ONNX vs Hugging Face outputs for prefill and decode steps
test/python/models/qwen_2.5_vl/run.sh Provides shell script to build and test models at different precisions (fp32, bf16, fp16)

Comment thread src/python/py/models/builders/qwen.py Outdated
Comment thread src/python/py/models/builders/qwen.py Outdated
Comment thread src/python/py/models/builders/qwen.py Outdated
Comment thread src/python/py/models/builders/qwen.py Outdated
Comment thread src/python/py/models/builders/qwen.py Outdated
Comment thread src/python/py/models/builders/qwen.py Outdated
Comment thread src/python/py/models/builder.py Outdated
Comment thread test/python/models/qwen_2.5_vl/run.sh Outdated
tianleiwu and others added 2 commits November 19, 2025 10:54
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Comment thread src/python/py/models/test_vl.py Fixed
@tianleiwu tianleiwu closed this Nov 19, 2025
@tianleiwu tianleiwu deleted the tlwu/qwen_2_5_vl_txt_model_builder branch November 19, 2025 22:22
@tianleiwu tianleiwu restored the tlwu/qwen_2_5_vl_txt_model_builder branch November 19, 2025 22:22
@tianleiwu tianleiwu reopened this Nov 19, 2025
Comment thread src/python/py/models/builders/qwen.py Outdated
Comment thread src/python/py/models/builders/qwen.py Outdated
Comment thread src/python/py/models/builders/qwen.py Outdated
Comment thread src/python/py/models/builders/qwen.py Outdated
Comment thread src/python/py/models/builders/qwen.py Outdated
Comment thread src/python/py/models/builders/qwen.py Outdated
Comment thread src/python/py/models/builders/qwen.py Outdated
Comment thread src/python/py/models/builders/qwen.py Outdated
Comment thread src/python/py/models/builders/qwen.py Outdated
Comment thread src/python/py/models/builders/base.py Outdated
Comment thread src/python/py/models/builders/base.py Outdated
Comment thread src/python/py/models/builders/qwen.py Outdated
Comment thread src/python/py/models/builders/qwen.py
Comment thread src/python/py/models/builders/qwen.py Outdated
Comment thread src/python/py/models/builders/qwen.py Outdated
Comment thread src/python/py/models/builders/qwen.py Fixed
Comment thread src/python/py/models/builders/qwen.py Outdated
Comment thread src/python/py/models/builders/qwen.py Outdated
Comment thread src/python/py/models/builders/qwen.py Outdated
@tianleiwu tianleiwu force-pushed the tlwu/qwen_2_5_vl_txt_model_builder branch from b103e50 to 88964ad Compare December 1, 2025 22:47
@tianleiwu tianleiwu enabled auto-merge (squash) December 3, 2025 06:46
@tianleiwu tianleiwu merged commit 8ce188d into main Dec 5, 2025
15 checks passed
@tianleiwu tianleiwu deleted the tlwu/qwen_2_5_vl_txt_model_builder branch December 5, 2025 00:40
kunal-vaishnavi pushed a commit that referenced this pull request Dec 5, 2025
Add model builder for Qwen2_5_VLTextModel.

Snippet of example test output:
```
onnxruntime-genai/test/python/models/qwen_2.5_vl$ bash run.sh fp32

...
--- Comparing Decode Logits ---
Logits: PASS

--- Comparing Decode KV Cache ---
KV Cache (all 72 tensors): PASS

✅ Decode Parity Test Passed!

==============================
🎉 All Parity Tests Passed! 🎉
==============================
--- fp32 run complete ---
```

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants